package com.bins.dentist.clinic.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.bins.dentist.clinic.model.dto.ClinicDto;
import com.bins.dentist.clinic.model.dto.ClinicPageDto;
import com.bins.dentist.clinic.model.vo.ClinicVo;
import com.bins.dentist.clinic.model.vo.ResultVo;
import com.bins.dentist.clinic.model.vo.SimpleSelectVo;
import com.bins.dentist.clinic.service.ClinicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 诊所表 前端控制器
 * </p>
 *
 * @author bins
 * @since 2023-04-23 13:22:36
 */
@RestController
@RequestMapping("/setting/clinic")
public class ClinicController {

    @Autowired
    private ClinicService clinicService;

    @GetMapping("/page")
    public ResultVo<IPage<ClinicVo>> pageList(ClinicPageDto pageDto) {
        return ResultVo.ok().data(clinicService.getPage(pageDto));
    }

    @GetMapping("/detail")
    public ResultVo<ClinicVo> detail(ClinicDto dto) {
        return ResultVo.ok().data(clinicService.getDetail(dto));
    }

    @PostMapping("/save")
    public ResultVo<ClinicVo> savePatient(@RequestBody ClinicDto dto) {
        return ResultVo.ok().data(clinicService.saveItem(dto));
    }

    @PostMapping("/delete")
    public ResultVo<Integer> deleteItem(@RequestBody ClinicDto dto){
        return ResultVo.ok().data(clinicService.deleteItem(dto));
    }

    @GetMapping("/select")
    public ResultVo<List<SimpleSelectVo>> selectList(ClinicDto dto) {
        return ResultVo.ok().data(clinicService.selectList(dto));
    }
}

